package com.olympus.hermes.order.service;

import com.olympus.hermes.common.service.AbstractService;
import com.olympus.hermes.common.support.PageRequest;
import com.olympus.hermes.order.bean.dto.order.CreateOrderDTO;
import com.olympus.hermes.order.domain.Order;
import com.olympus.hermes.order.repo.OrderRepo;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Mickey
 * @since 2021/2/3
 */
@Service
@AllArgsConstructor
public class OrderService extends AbstractService {

    private final OrderRepo orderRepo;

    public void create(CreateOrderDTO createOrder) {
        creatorFor(orderRepo)
                .instance(createOrder::convertTo)
                .call();
    }

    public Page<Order> list(PageRequest pageRequest) {
       return orderRepo.findAll(pageRequest);
    }


}
